package com.fastCms.manager.bim.controller;


import com.fastCms.business.bim.pojo.po.BannerSavePO;
import com.fastCms.business.bim.pojo.po.ChangeStatusPO;
import com.fastCms.business.bim.pojo.po.ScenePO;
import com.fastCms.business.bim.pojo.vo.BannerVO;
import com.fastCms.business.frame.exception.BusinessException;
import com.fastCms.business.frame.pojo.po.IdStrPO;
import com.fastCms.business.frame.response.ApiResponse;
import com.fastCms.business.frame.response.ResponseUtil;
import com.fastCms.business.frame.service.BannerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author quan
 * @since 2024-05-23
 */
@Api(value = "BannerController", tags = "轮播图管理")
@RestController
@RequestMapping("/banner")
public class BannerController {
    @Resource
    private BannerService bannerService;

    @PostMapping("/showList")
    @ApiOperation(value = "列表", notes = "根据业务场景筛选 scene:BANNER_WXMINI_INDEX-微信小程序首页轮播")
    public ApiResponse<List<BannerVO>> create(@RequestBody ScenePO param) {
        List<BannerVO> result = bannerService.showList(param);
        return ResponseUtil.success(result);
    }

    @PostMapping("/saveOrUpdate")
    @ApiOperation(value = "新建或更新", notes = "")
    public ApiResponse<Boolean> saveOrUpdate(@RequestBody BannerSavePO param) throws BusinessException {
        Boolean result = bannerService.saveOrUpdate(param);
        return ResponseUtil.success(result);
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除", notes = "")
    public ApiResponse<Boolean> delete(@RequestBody IdStrPO param) throws BusinessException {
        Boolean result = bannerService.delete(param);
        return ResponseUtil.success(result);
    }

    @PostMapping("/changeStatus")
    @ApiOperation(value = "改变状态", notes = "1-展示 0-不展示")
    public ApiResponse<Boolean> changeStatus(@RequestBody ChangeStatusPO param) throws BusinessException {
        Boolean result = bannerService.changeStatus(param);
        return ResponseUtil.success(result);
    }
}

